package com.weedsdream.app.struct

import android.content.Context.MODE_PRIVATE
import com.weedsdream.BaseActivity

/**SharePreference操作*/
object SpOpe {
    private val sp = BaseActivity.activity.getSharedPreferences("WSM_SP", MODE_PRIVATE)

    /**保存数值*/
    fun save(value: String, key: String = "lastProject") {
        sp.edit().putString(key, value).apply()// 或者使用commit()，但 apply() 更推荐，因为它是异步的
    }

    /**读取数值*/
    fun read(key: String = "lastProject") = sp.getString(key, null)

    /**删除数据*/
    fun delete(key: String = "lastProject") {
        sp.edit().remove(key).apply()
    }
}